package com.ssm.demo.controller;

import com.ssm.demo.pojo.Book;
import com.ssm.demo.pojo.PageBean;
import com.ssm.demo.pojo.VO.ResultVO;
import com.ssm.demo.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/book")
public class BookController {
    @Autowired
    private BookService bookService;

    @GetMapping("/list")
    public ResultVO<?> list(Integer pageNum, Integer pageSize){
        return bookService.getBooks(pageNum, pageSize);
    }

    @DeleteMapping("/delete")
    @ResponseBody
    public ResultVO<?> del(Integer bookId){
        return bookService.delBook(bookId);
    }

    @PostMapping("/add")
    @ResponseBody
    public ResultVO<?> add(@RequestBody Book book){
        return bookService.addBook(book);
    }


}
